package com.design3.graduatethesissys.service.impl;

import java.awt.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.design3.graduatethesissys.common.utils.GetUserName;
import com.design3.graduatethesissys.common.utils.UUIDUtils;
import com.design3.graduatethesissys.domain.Subject;
import com.design3.graduatethesissys.mapper.StudentMapper;
import com.design3.graduatethesissys.mapper.SubjectMapper;
import com.design3.graduatethesissys.mapper.TehStuSubMapper;
import com.design3.graduatethesissys.service.XuantiService;

/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月9日 下午6:03:20 
* 类说明 
*/
@Service
public class XuantiServiceImpl implements XuantiService{

	@Autowired
	StudentMapper studentMapper;
	
	@Autowired
	TehStuSubMapper tehStuSubMapper;
	
	@Autowired
	SubjectMapper subjectMapper;
	
	@Override
	@Transactional(rollbackFor = {RuntimeException.class, Error.class}) // 事务
	public String xuanTi(String sbj_id, String teh_id) {
		String username = GetUserName.getUserName();
		String id = UUIDUtils.getUUID();
		try {			
			System.out.println(1);
			studentMapper.UpdateStuSubjectByStudentId(username,sbj_id);
			System.out.println(2);
			subjectMapper.updateSubject(sbj_id);
			System.out.println(3);
			tehStuSubMapper.InsertTeh_Stu_Sub(id,username,sbj_id,teh_id);
			System.out.println();
			return "success";
		} catch (Exception e) {
			return "false";
		}
		
	}

	public Subject searchSubjectByStuId(String userName) {
		// TODO Auto-generated method stub
		return subjectMapper.searchSubjectByStuId(userName);
	}

	
}
 